package ru.evga.billboard.graph.preference;

public class IntParam
    extends Param<Integer>
{
    private Integer min;
    private Integer max;
    
    public IntParam(String key, Integer defaultValue, Integer min, Integer max)
    {
        super(key, defaultValue);
        this.min = min;
        this.max = max;
    }

    public void fromString(String strValue)
    {
        if (strValue == null)
        {
            setValue(getDefaultValue());
        }
        else
        {
            try
            {
                setValue(Integer.valueOf(strValue));
            }
            catch (Exception e)
            {
                setValue(getDefaultValue());
            }
        }
    }

    public String toString()
    {
        return String.valueOf(getValue());
    }

    public Integer getMin()
    {
        return min;
    }

    public Integer getMax()
    {
        return max;
    }
}
